package org.pz.camunda.controller;

import com.netflix.discovery.converters.Auto;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.pz.camunda.service.DeployService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 部署相关
 * */
@RestController
public class DeployController {

    @Autowired
    private DeployService deployService;

    /**
     * @param resourcePath 流程图路径
     * @param name  流程名称
     * */
    @RequestMapping("/deploy")
    public void deploy(@RequestParam String resourcePath, String name) {
        deployService.deploy(resourcePath, name);
    }

    /**
     * @param deploymentId 部署 id
     * */
    @RequestMapping("/undeploy")
    public void undeploy(@RequestParam String deploymentId) {
        deployService.undeploy(deploymentId);
    }

    /**
     * 获取流程模型实例
     */
    @RequestMapping("/getInstances")
    public BpmnModelInstance getBpmnModelInstance(@RequestParam String deploymentId) {
        return deployService.getBpmnModelInstance( deploymentId );
    }
}
